package metric

import (
	"htgis/monitor/common/model"
	"strings"
)

// newMetricValue constructs collected information struct
func newMetricValue(metric string, val interface{}, dataType string, tags ...string) *model.MetricValue {
	mv := model.MetricValue{
		Metric: metric,
		Value:  val,
		Type:   dataType,
	}

	size := len(tags)
	if size > 0 {
		mv.Tags = strings.Join(tags, ",")
	}

	return &mv

}

// GaugeValue constructs origin type of rrd
func GaugeValue(metric string, val interface{}, tags ...string) *model.MetricValue {
	return newMetricValue(metric, val, "GAUGE", tags...)
}

// CounterValue constructs counter type of rrd
func CounterValue(metric string, val interface{}, tags ...string) *model.MetricValue {
	return newMetricValue(metric, val, "COUNTER", tags...)
}
